package com.durian.base.frame.activity;

import android.content.Intent;
import android.view.KeyEvent;
import androidx.annotation.Nullable;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.durian.base.R;
import com.durian.base.frame.easyrouter.EasyRouter;
import com.durian.base.frame.titlebar.ISuperTitleBar;

/**
 * 说明：ActivityBindFragment
 * <p/>
 * 作者：fanly
 * <p/>
 * 类型：Class
 * <p/>
 * 时间：2019-06-29 16:29
 * <p/>
 * 版本：version 1.0
 */
@Route(path = EasyRouter.PATH_BIND_FRAGMENT)
public class ActivityBindFragment extends ActivityFrame{

    private BindFragmentSupport mBindFragmentSupport = new BindFragmentSupport();

    @Override
    public int getRootViewResID() {
        return R.layout.base_activity_bind_fragment;
    }

    @Override
    public void onInitStart(){
        if (mBindFragmentSupport.getFragment() != null){
            replaceFragment(R.id.fl_content, mBindFragmentSupport.getFragment());
        }
    }

    @Override
    public void getIntentData(Intent intent) {
        super.getIntentData(intent);
        mBindFragmentSupport.getIntentData(intent);
    }

    @Override
    public ISuperTitleBar bindSuperTitleBar() {
        return mBindFragmentSupport.bindSuperTitleBar();
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        mBindFragmentSupport.onActivityResult(requestCode,resultCode,data);
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (mBindFragmentSupport.onKeyDown(keyCode,event)){
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }

    @Override
    protected void onDestroy() {
        mBindFragmentSupport.onDestroy(this);
        super.onDestroy();
    }

}
